import React, { useState, useEffect } from "react";
import { feedbackList } from "../API/feedbackAPI";
import "../css/feedback.less";
import { useHistory } from "react-router-dom";
import { Card } from "antd-mobile";
import Header from "../../Header";

export default function FeedBackList() {
  const [list, setlist]: any = useState([]);
  const history = useHistory();

  const getList = async () => {
    let res = await feedbackList();
    // console.log(res);
    // eslint-disable-next-line eqeqeq
    if (res.data.code == 200) {
      setlist(res.data.rows);
    }
  };

  const click = (id: any) => {
    console.log(id);
    window.localStorage.setItem("id", id);
    history.push(`/mine/details/${id}`);
  };

  useEffect(() => {
    getList();
  }, []);

  return (
    <>
    <Header title="反馈列表"></Header>
      <div className="boss xz-content">
        {list.map((item: any) => {
          return (
            <Card
              className="card"
              title={item.title}
              key={item.id}
              extra={item.createTime}
              onClick={() => {
                click(item.id);
              }}
            >
              <b>内容：</b>
              {item.content}
            </Card>
            // </div>
          );
        })}
      </div>
    </>
  );
}
